package com.example.memonto;

import java.util.Stack;

/**
 * 备忘录
 */
public class TextHistory {
    private final Stack<TextMemonto> history = new Stack<>();

    // 保存
    public void save(TextMemonto m) {
        history.push(m);
    }

    // 撤销
    public TextMemonto undo() {
        if (history.isEmpty()) {
            return null;
        }
        return history.pop();
    }

    @Override
    public String toString() {
        return "TextHistory{" +
                "history=" + history +
                '}';
    }
}
